import unittest
from unittest.mock import patch, MagicMock
from flask import jsonify
from routes.gep_route import gep_parameters


class GepRoutesTest(unittest.TestCase):
    @patch('routes.gep_routes.request')
    @patch('routes.gep_routes.gep_service')
    def test_post_request_with_valid_data(self, mock_gep_service, mock_request):
        # Setup mock objects
        mock_request.method = 'POST'
        mock_request.json = {
            'param1': 'value1',
            'param2': 'value2'
        }
        
        # Create a mock GepParameter object
        mock_gep_parameter = MagicMock()
        mock_gep_parameter.to_dict.return_value = {
            'id': 1,
            'param1': 'value1',
            'param2': 'value2'
        }
        
        # Configure the mock service
        mock_gep_service.add_gep_parameter.return_value = mock_gep_parameter
        
        # Call the function
        response, status_code = gep_parameters()
        
        # Assertions
        mock_gep_service.add_gep_parameter.assert_called_once_with(mock_request.json)
        self.assertEqual(status_code, 201)
        self.assertEqual(response, jsonify(mock_gep_parameter.to_dict()))
        mock_gep_parameter.to_dict.assert_called_once()


if __name__ == '__main__':
    unittest.main()